# ！！！！！！！！！！！！！！001！！！！！！！！！
# a=100
# if a>100:
#     print("a>100")
# elif (a==50):
#     print("a==50")
# else:
#     print(a)
# e=101
# # for循环
# l=[1a,2b,3,4,5,6]
# for i in l:
#     print(i)
# print(f"final e:{e}")   #final e:101

# l=['1a','2b',3,4,5,6]
# for inde,valu in enumerate(l):  #enumerate列举、枚举
#     print(f"index:{inde},value:{valu}")
# # 输出见下：
# # index:0,value:1a
# # index:1,value:2b
# # index:2,value:3
# # index:3,value:4
# # index:4,value:5
# # index:5,value:6

# ！！！！！！！！！！！！！！002！！！！！！！！！
# count=0
# while count<18:
#     print(f"sim statement:{count}")
#     count+=1

# count=0
# x=12
# while True:#死循环
#     if count>x:
#         break
#     print(f"sim statement:{count}")
#     count+=1
# l=[1,2,3,4,5,6,7]
# for i in l:
#     print(f"search element:{i}")
#     if i==3:
#         break
# ！！！！！！！！！！！！！！003！！！！！！！！！
# l=[1,2,3,4,5]
# for i in l:
#     if i==3: #遇到3就跳过；
#         continue
#     else:
#         print(f"search element;{i}")
#     print("for循环的最后一句",i,"-----")
# search element;1
# for循环的最后一句 1 -----
# search element;2
# for循环的最后一句 2 -----
# search element;4
# for循环的最后一句 4 -----
# search element;5
# for循环的最后一句 5 -----

# l=[1,2,3,4,5]
# for i in l:
#     if i==3: #遇到3就跳过；if外，for里面的还是要执行的
#         pass
#     else:
#         print(f"search element;{i}")
#     print("for循环的最后一句",i,"------------")
# search element;1
# for循环的最后一句 1 ------------
# search element;2
# for循环的最后一句 2 ------------
# for循环的最后一句 3 ------------
# search element;4
# for循环的最后一句 4 ------------
# search element;5
# for循环的最后一句 5 ------------
# ！！！！！！！！！！！！！！004！！！！！！！！！
# 异常
# def my_sub(a,b):
#     return a/b
# print(my_sub(1,0))
# def my_sub(a,b):
#     try:
#         return a/b
#     except Exception as e:
#         # print(e)
#         print("分母不能为0")
#         return None
#     finally:
#         print("my_sub,end")
#         # f.close()
# print(my_sub(2,0))

# 常见异常
# l=[1,2]
# l[2]
# Traceback (most recent call last):
#   File "<input>", line 1, in <module>
# IndexError: list index out of range
# ！！！！！！！！！！！！！！005！！！！！！！！！
# def my_sub(a, b):
#     try:
#         return a / b
#     except ZeroDivisionError:
#         print("分母不可为0")
#         raise Exception("params error")#继续抛出错误；参数错误；
#     finally:
#         print("function my_sub end")
#
# my_sub(1,0)

# zidignyi自定义
class ParamsError(Exception):
    pass


def my_sub(a, b):
    try:
        return a / b
    except ZeroDivisionError:
        raise ParamsError("分母不可以为0")
    finally:
        print("function my_sub end")

print(my_sub(1,2))
print(my_sub(1,0))








